#define _CRT_SECURE_NO_WARNINGS 1;
#include <iostream>
#include <cstdlib>
#include <windows.h>
using namespace std;
class Graduate {
private:
	char* name;
	bool gender; 
	int id;
	double score;
	string research;
	string tutor;
	static double totalScore;
	static int count;
public:
	Graduate() {

	}
	Graduate(const char* name, bool gender, int id, double score, const string& research, const string& tutor)
		: gender(gender), id(id), score(score), research(research), tutor(tutor) {
		this->name = new char[strlen(name) + 1];
		strcpy(this->name, name);
		totalScore += score;
		count++;
	}
	Graduate(const Graduate& other)
		: gender(other.gender), id(other.id), score(other.score), research(other.research), tutor(other.tutor) {
		name = new char[strlen(other.name) + 1];
		strcpy(name, other.name);
		totalScore += score;
		count++;
	}
	void displayInfo() {
		cout << "Name: " << name << endl;
		cout << "Gender: " << (gender ? "Male" : "Female") << endl;
		cout << "ID: " << id << endl;
		cout << "Score: " << score << endl;
		cout << "Research Field: " << research << endl;
		cout << "Tutor: " << tutor << endl;
	}
	void displayInfo() const {
		cout << "Name: " << name << endl;
		cout << "Gender: " << (gender ? "Male" : "Female") << endl;
		cout << "ID: " << id << endl;
		cout << "Score: " << score << endl;
		cout << "Research Field: " << research << endl;
		cout << "Tutor: " << tutor << endl;
	}
	static double calculateAverageScore() {
		return count > 0 ? totalScore / count : 0.0;
	}
	~Graduate() {
		delete[] name;
		totalScore -= score;
		count--; 
	}
	friend char Grade(const Graduate& grad);
};
char Grade(const Graduate& grad) {
	if (grad.score >= 90) return 'A';
	if (grad.score >= 80) return 'B';
	if (grad.score >= 70) return 'C';
	if (grad.score >= 60) return 'D';
	return 'E';
}
double Graduate::totalScore = 0;
int Graduate::count = 0;
int main()
{
	Graduate grad1("Alice", false, 1001, 85.5, "Computer Science", "Dr. Q");
	Graduate grad2("Bob", true, 1002, 92.0, "Math", "Dr. J");
	Graduate grad3("Fuccch", true, 1003, 30, "Medicine", "Dr. F");
	grad1.displayInfo();
	cout << "Grade: " << Grade(grad1) << endl;
	grad2.displayInfo();
	cout << "Grade: " << Grade(grad2) << endl;
	grad3.displayInfo();
	cout << "Grade: " << Grade(grad3) << endl;
	cout << "Average Score: " << Graduate::calculateAverageScore() << endl;
	system("pause");
	
	return 0;
}